package com.yzh.design.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

public abstract class NetMall {
    protected Logger logger = LoggerFactory.getLogger(NetMall.class);
    
    private String uId;
    private String uPwd;

    public NetMall(String id, String uPwd) {
        this.uId = id;
        this.uPwd = uPwd;
    }

    /**
     * 生成海报
     * @param skuUrl 商品地址(京东、淘宝、当当)
     * @return 海报图片base64位信息
     */
    public String generateGoodsPoster(String skuUrl) {
        if (!login(uId, uPwd)) return null;             //1.用户登录    
        Map<String, String> reptile = reptile(skuUrl);  //2.爬取信息
        return createBase64(reptile);                   //3.生成海报
    }
    //模拟登录
    protected abstract Boolean login(String uId, String uPwd);
    //爬取信息
    protected abstract Map<String, String> reptile(String skuUrl);
    protected abstract String createBase64(Map<String, String> goodsInfo);
}
